package com.gla.Controller;

import com.gla.domain.Commodity;
import com.gla.domain.Shop;
import com.gla.result.Result;
import com.gla.service.FYH_ShopService;
import com.gla.service.SearchService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/Search")
public class SearchController {
    @Resource
    SearchService searchService;

    @GetMapping("/getNearShop")
    public Result getNearShop(Double latitude,Double longitude){

        List<Shop> nearshop = searchService.selectNearShop(latitude,longitude);
        return Result.succeed(nearshop);
    }

    @GetMapping("/getSearchShop")
    public Result getSearchShop(String keyword){
        List<Shop> searchShop = searchService.searchShop(keyword);
        return Result.succeed(searchShop);
    }

    @GetMapping("/getSearchPet")
    public Result getSearchPet(String keyword){
        List<Commodity> searchPet = searchService.searchPet(keyword);
        return Result.succeed(searchPet);
    }

    @GetMapping("/getSearchPetGoods")
    public Result getSearchPetGoods(String keyword){
        List<Commodity> searchPetGoods = searchService.searchPetGoods(keyword);
        return Result.succeed(searchPetGoods);
    }

    @GetMapping("/getSearchFine")
    public Result getSearchFine(Integer cat,Integer dog,Integer chuxing,Integer weisheng,Integer wanju,Integer shiping){
        List<Commodity> SearchFine = searchService.getSearchFine(cat,dog,chuxing,weisheng,wanju,shiping);
        return Result.succeed(SearchFine);
    }
}
